<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">



<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css">


  <meta name="keywords" content="Laravel,easyWechat,Wechat,">








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0">






<meta name="description" content="环境与部署基于Laravel5.4 和 easywechat 框架制作，以下说明了部署过程，框架使用，核心代码，一些问题解决方案。 环境需求 PHP &amp;gt;= 5.5.9 (PHP 7 的时代了，我在开发中一直用的PHP7) PHP cURL 扩展 PHP OpenSSL 扩展 PHP fileinfo 拓展 素材管理模块需要用到（微信公众号权限不够暂时用不到）  开始部署 安装Laravel框">
<meta name="keywords" content="Laravel,easyWechat,Wechat">
<meta property="og:type" content="article">
<meta property="og:title" content="Laravel微信公众号游戏查询">
<meta property="og:url" content="http://blog.vimc.cc/2017/05/22/Laravel微信公众号开发/index.html">
<meta property="og:site_name" content="你的口袋有什么？">
<meta property="og:description" content="环境与部署基于Laravel5.4 和 easywechat 框架制作，以下说明了部署过程，框架使用，核心代码，一些问题解决方案。 环境需求 PHP &amp;gt;= 5.5.9 (PHP 7 的时代了，我在开发中一直用的PHP7) PHP cURL 扩展 PHP OpenSSL 扩展 PHP fileinfo 拓展 素材管理模块需要用到（微信公众号权限不够暂时用不到）  开始部署 安装Laravel框">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://oqca0721d.bkt.clouddn.com/IMG_0112.PNG">
<meta property="og:image" content="http://oqca0721d.bkt.clouddn.com/wechat2.png">
<meta property="og:image" content="http://oqca0721d.bkt.clouddn.com/kitokoto.png">
<meta property="og:image" content="http://oqca0721d.bkt.clouddn.com/424cye1496637209.png">
<meta property="og:image" content="http://oqca0721d.bkt.clouddn.com/gnh6gu1496637653.png">
<meta property="og:image" content="http://oqca0721d.bkt.clouddn.com/2u4fcy1496638069.png">
<meta property="og:updated_time" content="2017-06-09T00:57:52.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Laravel微信公众号游戏查询">
<meta name="twitter:description" content="环境与部署基于Laravel5.4 和 easywechat 框架制作，以下说明了部署过程，框架使用，核心代码，一些问题解决方案。 环境需求 PHP &amp;gt;= 5.5.9 (PHP 7 的时代了，我在开发中一直用的PHP7) PHP cURL 扩展 PHP OpenSSL 扩展 PHP fileinfo 拓展 素材管理模块需要用到（微信公众号权限不够暂时用不到）  开始部署 安装Laravel框">
<meta name="twitter:image" content="http://oqca0721d.bkt.clouddn.com/IMG_0112.PNG">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 'undefined',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://blog.vimc.cc/2017/05/22/Laravel微信公众号开发/">





  <title> Laravel微信公众号游戏查询 | 你的口袋有什么？ </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?ac9533e5100bee8b75e87a8bb5e51c10";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">你的口袋有什么？</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">Ghost's Blog</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-wisdom">
          <a href="/resume" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br>
            
            简历
          </a>
        </li>
      
        
        <li class="menu-item menu-item-support">
          <a href="/support" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-support"></i> <br>
            
            赞助
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.vimc.cc/2017/05/22/Laravel微信公众号开发/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Colorful_Ghost">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="你的口袋有什么？">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                Laravel微信公众号游戏查询
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-05-22T08:56:22+08:00">
                2017-05-22
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/教程/" itemprop="url" rel="index">
                    <span itemprop="name">教程</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="环境与部署"><a href="#环境与部署" class="headerlink" title="环境与部署"></a>环境与部署</h2><p>基于Laravel5.4 和 easywechat 框架制作，以下说明了部署过程，框架使用，核心代码，一些问题解决方案。</p>
<h3 id="环境需求"><a href="#环境需求" class="headerlink" title="环境需求"></a>环境需求</h3><ul>
<li>PHP &gt;= 5.5.9 (PHP 7 的时代了，我在开发中一直用的PHP7)</li>
<li>PHP cURL 扩展</li>
<li>PHP OpenSSL 扩展</li>
<li>PHP fileinfo 拓展 素材管理模块需要用到（微信公众号权限不够暂时用不到）</li>
</ul>
<h3 id="开始部署"><a href="#开始部署" class="headerlink" title="开始部署"></a>开始部署</h3><blockquote>
<p>安装Laravel框架<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">composer create-project laravel/laravel wechat --prefer-dist</span><br></pre></td></tr></table></figure></p>
<p>安装laravel-wechat框架<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">composer require <span class="string">"overtrue/wechat:~3.3"</span> -vvv</span><br></pre></td></tr></table></figure></p>
</blockquote>
<h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2><blockquote>
<p>注册服务提供者</p>
</blockquote>
<ul>
<li><p>在目录 <code>config/app.php</code>下<code>providers</code>数组里添加：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Overtrue\LaravelWechat\ServiceProvider::class,</span><br></pre></td></tr></table></figure>
</li>
<li><p>创建配置文件：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">php artisan vendor:publish --provider=<span class="string">"Overtrue\LaravelWechat\ServiceProvider"</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>修改应用根目录下的 config/wechat.php 中对应的项即可；</p>
</li>
<li><p>添加外观到 config/app.php 中的 aliases 部分：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">'EasyWeChat'</span> =&gt; Overtrue\LaravelWechat\Facade::class,</span><br></pre></td></tr></table></figure>
</li>
</ul>
<ul>
<li><code>ServiceProvider</code>和<code>Facade</code>具体用法看下面的其他<a href="#其他调用SDK方法">其他调用SDK方法</a></li>
</ul>
<h2 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h2><p>Laravel 5.2 以后的版本默认启用了 web 中间件，意味着 CSRF 会默认打开，有两种方案：</p>
<ol>
<li><p>在 CSRF 中间件里排除微信相关的路由，添加例外路由，在<code>app\Http\Middleware\VerifyCsrfToken.php</code></p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">protected</span> $except = [</span><br><span class="line">     <span class="string">'wechat'</span></span><br><span class="line">];</span><br></pre></td></tr></table></figure>
</li>
<li><p>关掉 CSRF 中间件（极不推荐）</p>
</li>
</ol>
<p>路由：<br><figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Route::any(<span class="string">'/wechat'</span>, <span class="string">'WechatController@serve'</span>);</span><br></pre></td></tr></table></figure></p>
<p>“开发者中心” 修改 “URL（服务器配置）” 为： <a href="http://codinger.cn/wechat" target="_blank" rel="noopener">http://codinger.cn/wechat</a></p>
<blockquote>
<p>注意：一定是 Route::any, 因为微信服务端认证的时候是 GET, 接收用户消息时是 POST ！</p>
</blockquote>
<p>然后创建控制器 WechatController<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">php artisan make:controller WechatController</span><br></pre></td></tr></table></figure></p>
<p>载入第三方类库：</p>
<p>在控制器目录下创建一个Tools文件夹，放入第三方类库文件夹。这里我使用的是</p>
<p><a href="https://code.google.com/archive/p/phpquery/downloads" target="_blank" rel="noopener">PHPQuery</a>一个爬网站的工具，写到WechatController里。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">require <span class="string">'Tools\phpQuery\phpQuery.php'</span>;</span><br></pre></td></tr></table></figure>
<p>实用composer自动加载，这样我们就可以直接在控制器里使用它了<code>use phpQuery;</code></p>
<p>因为我要对Minecraft服务端进行获取服务器信息和在线人数，使用一个别人写好的库<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">composer require xpaw/php-minecraft-query</span><br></pre></td></tr></table></figure></p>
<p>现在开始写WechatController控制器：<br><figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?php</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">namespace</span> <span class="title">App</span>\<span class="title">Http</span>\<span class="title">Controllers</span>;</span><br><span class="line"><span class="keyword">use</span> <span class="title">EasyWeChat</span>\<span class="title">Message</span>\<span class="title">Text</span>;</span><br><span class="line"><span class="keyword">use</span> <span class="title">Illuminate</span>\<span class="title">Http</span>\<span class="title">Request</span>;</span><br><span class="line"><span class="keyword">use</span> <span class="title">Illuminate</span>\<span class="title">Support</span>\<span class="title">Facades</span>\<span class="title">Log</span>;</span><br><span class="line"><span class="keyword">use</span> <span class="title">xPaw</span>\<span class="title">MinecraftPing</span>;</span><br><span class="line"><span class="keyword">use</span> <span class="title">xPaw</span>\<span class="title">MinecraftPingException</span>;</span><br><span class="line"><span class="keyword">require</span> <span class="string">'Tools\phpQuery\phpQuery.php'</span>;<span class="comment">//抓取网页数据的类</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">WechatController</span> <span class="keyword">extends</span> <span class="title">Controller</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 处理微信的请求消息</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span> string</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">serve</span><span class="params">()</span></span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">#  Log::info('响应请求.'); # Log 为 Laravel 组件，所以它记的日志去 Laravel 日志看，而不是 EasyWeChat 日志</span></span><br><span class="line">        $weChat = app(<span class="string">'wechat'</span>);<span class="comment">//// 从项目实例中得到服务端应用实例。</span></span><br><span class="line">        $weChat-&gt;server-&gt;setMessageHandler(<span class="function"><span class="keyword">function</span><span class="params">($message)</span></span>&#123;<span class="comment">//使用 setMessageHandler(callable $callback) 来设置消息处理函数</span></span><br><span class="line">            <span class="keyword">switch</span> ($message-&gt;MsgType)&#123;<span class="comment">//检查消息类型</span></span><br><span class="line">                <span class="keyword">case</span> <span class="string">'event'</span>:</span><br><span class="line">                    <span class="keyword">if</span> ($message-&gt;Event == <span class="string">'subscribe'</span>)&#123;</span><br><span class="line">                        $text = <span class="keyword">new</span> Text([</span><br><span class="line">                            <span class="string">'content'</span>=&gt;<span class="string">"感谢您关注一言查询机器人\n例:正版玩家Player 查询Minecraft正版玩家\n例:服务器mc.Decraft.cc(默认端口25565) 查询游戏服务器\n还可以用语音来调教我XD\n文字召唤机器人需要在前面加上'小冰'即可"</span></span><br><span class="line">                        ]);</span><br><span class="line">                        <span class="keyword">return</span> $text;</span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                <span class="keyword">case</span> <span class="string">'text'</span>:</span><br><span class="line">                    <span class="keyword">return</span> <span class="keyword">$this</span>-&gt;pqText($message-&gt;Content); <span class="comment">//对接受的文字内容进行住处理</span></span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                <span class="keyword">case</span> <span class="string">'image'</span>:</span><br><span class="line">                    <span class="keyword">return</span> <span class="string">'emmm,我没有对图片写相关功能，可以使用机器人查询你想要的图片 '</span>;</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                <span class="keyword">case</span> <span class="string">'voice'</span>:</span><br><span class="line">                    <span class="keyword">return</span> <span class="keyword">$this</span>-&gt;pqVoice($message-&gt;Recognition); <span class="comment">//对接受的语音消息转换文字处理</span></span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                <span class="keyword">case</span> <span class="string">'video'</span>:</span><br><span class="line">                    <span class="keyword">return</span> <span class="string">'因为管理员很懒没有写对视频的功能，如果让我添加也可以哦！'</span>;</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                <span class="keyword">case</span> <span class="string">'location'</span>:</span><br><span class="line">                    <span class="keyword">return</span> <span class="string">'因为管理员很懒没有写对坐标的功能，如果让我添加也可以哦！'</span>;</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                <span class="keyword">case</span> <span class="string">'link'</span>:</span><br><span class="line">                    <span class="keyword">return</span> <span class="string">'因为管理员很懒没有写对链接的功能，如果让我添加也可以哦！'</span>;</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                <span class="comment">// ... 其它消息</span></span><br><span class="line">                <span class="keyword">default</span>:</span><br><span class="line">                    <span class="keyword">return</span> <span class="string">'暂时不支持其它消息'</span>;</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;);</span><br><span class="line">        <span class="comment"># Log::info('返回请求完成');</span></span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> $weChat-&gt;server-&gt;serve();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">pqText</span><span class="params">($content)</span></span>&#123;<span class="comment">//对文字进行匹配，修剪，对空格的删除</span></span><br><span class="line">         <span class="keyword">if</span> (mb_substr($content,<span class="number">0</span>,<span class="number">4</span>)==<span class="string">'正版玩家'</span>)&#123;</span><br><span class="line">            $playername = ltrim($content,<span class="string">'正版玩家'</span>);</span><br><span class="line">            $playername = str_replace(<span class="string">' '</span>,<span class="string">''</span>,$playername);</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">$this</span>-&gt;playerSearch($playername);</span><br><span class="line"></span><br><span class="line">        &#125;<span class="keyword">else</span> <span class="keyword">if</span> (mb_substr($content,<span class="number">0</span>,<span class="number">3</span>)==<span class="string">'服务器'</span>)&#123;</span><br><span class="line">            $address = ltrim($content,<span class="string">'服务器'</span>);</span><br><span class="line">            $address = str_replace(<span class="string">' '</span>,<span class="string">''</span>,$address);</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">$this</span>-&gt;serverQuery($address);</span><br><span class="line">        &#125;<span class="keyword">else</span> <span class="keyword">if</span>(mb_substr($content,<span class="number">0</span>,<span class="number">2</span>)==<span class="string">'小冰'</span>)&#123;</span><br><span class="line">            $ice = ltrim($content,<span class="string">'小冰'</span>);</span><br><span class="line">            $ice = str_replace(<span class="string">' '</span>,<span class="string">''</span>,$ice);</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">$this</span>-&gt;bot($ice);</span><br><span class="line">        &#125;<span class="keyword">else</span> <span class="keyword">if</span>($content==<span class="string">'一言'</span>)&#123;</span><br><span class="line">            $hitokoto= <span class="keyword">$this</span>-&gt;hitokoto();</span><br><span class="line">            <span class="keyword">return</span> $hitokoto[<span class="string">'hitokoto'</span>].<span class="string">"\n                    ——"</span>.$hitokoto[<span class="string">'from'</span>];</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">else</span>&#123;<span class="comment">//对其他文字消息进行功能性提示</span></span><br><span class="line">            $another = <span class="string">"游戏查询功能例如下: \n"</span>;</span><br><span class="line">            $another.= <span class="string">"正版玩家Colorful_Ghost\n"</span>;</span><br><span class="line">            $another.= <span class="string">"服务器	mc.Decraft.cc\n"</span>;</span><br><span class="line">            $another.= <span class="string">"一言\n"</span>;</span><br><span class="line">            $another.= <span class="string">"额外功能：召唤小冰\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰蚌埠天气怎样\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰水瓶座今日运势\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰蚌埠天气怎样\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰讲个笑话\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰讲个故事\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰成语接龙一诺千金\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰周杰伦这个名字好不好\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰图灵的简介\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰图灵的图片\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰查询快递123456789\n"</span>;</span><br><span class="line">            $another.= <span class="string">"小冰说个绕口令~\n"</span>;</span><br><span class="line">            $another.= <span class="string">"现在小冰支持语音功能啦！直接对提问翻译都可以哦！\n"</span>;</span><br><span class="line">            $another.= <span class="string">"更多功能陆续添加等你测试~\n"</span>;</span><br><span class="line">            <span class="keyword">return</span> $another;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">pqVoice</span><span class="params">($content)</span></span>&#123;<span class="comment">//对语音消息的处理</span></span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">$this</span>-&gt;bot($content);<span class="comment">//把语音消息让机器人处理</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">serverQuery</span><span class="params">($host,$port = <span class="number">25565</span>)</span></span>&#123;<span class="comment">//对Minecraft服务器进行查询,使用了composer第三方包xpaw/php-minecraft-query</span></span><br><span class="line">        <span class="keyword">try</span>&#123;</span><br><span class="line">            $query = <span class="keyword">new</span> MinecraftPing($host,$port);</span><br><span class="line">            <span class="keyword">if</span> (!$query-&gt;Connect()) &#123;</span><br><span class="line">                $status = $query-&gt;Query();</span><br><span class="line">                $result = <span class="string">"在线人数:"</span> . $status[<span class="string">'players'</span>][<span class="string">'online'</span>] . <span class="string">'/'</span> . $status[<span class="string">'players'</span>][<span class="string">'max'</span>] . <span class="string">"\n服务器版本:"</span> . $status[<span class="string">'version'</span>][<span class="string">'name'</span>] . <span class="string">"\n服务器简介:"</span> . $status[<span class="string">'description'</span>][<span class="string">'text'</span>];</span><br><span class="line">                <span class="keyword">return</span> $result;</span><br><span class="line">            &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                <span class="keyword">return</span> <span class="string">'服务器不存在，或者IP地址错误！'</span>;</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">        &#125;<span class="keyword">catch</span> (MinecraftPingException $e)&#123;</span><br><span class="line">            Log::info($e-&gt;getMessage());</span><br><span class="line">        &#125;<span class="keyword">finally</span>&#123;</span><br><span class="line">           $query-&gt;Close();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">playerSearch</span><span class="params">($player)</span></span>&#123;<span class="comment">//对Minecraft 正版玩家的信息查询，包括玩家用户名 ，UUID,皮肤数据</span></span><br><span class="line">        \phpQuery::newDocumentFile(<span class="string">'https://mcuuid.net/?q='</span>.$player);<span class="comment">//对mcuuid这个网站进行数据采集工作</span></span><br><span class="line">        <span class="keyword">if</span>(pq(<span class="string">'h3:first'</span>)-&gt;html()==<span class="string">'Useful Minecraft Resources'</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="string">'用户不存在,或者请求过多稍后再试'</span>;</span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            $playerdata[<span class="string">'username'</span>] = pq(<span class="string">'h3:first'</span>)-&gt;html();</span><br><span class="line">            $playerdata[<span class="string">'uuid'</span>]  = pq(<span class="string">'input.form-control:last'</span>)-&gt;attr(<span class="string">'value'</span>);</span><br><span class="line">            $playerdata[<span class="string">'skin'</span>]  = pq(<span class="string">'img:last'</span>)-&gt;attr(<span class="string">'src'</span>);</span><br><span class="line"></span><br><span class="line">            $result = <span class="string">"玩家用户名:"</span>.$playerdata[<span class="string">'username'</span>].<span class="string">"\n玩家UUID:"</span>.$playerdata[<span class="string">'uuid'</span>].<span class="string">"\n玩家皮肤:"</span>.$playerdata[<span class="string">'skin'</span>];</span><br><span class="line">            <span class="keyword">return</span> $result;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">hitokoto</span><span class="params">()</span></span>&#123;<span class="comment">//调用一言API,具体API调用方法参考一言API ： http://hitokoto.cn/api</span></span><br><span class="line">        $url = <span class="string">'http://api.hitokoto.cn/?encode=json'</span>;</span><br><span class="line">        $json = file_get_contents($url);</span><br><span class="line">        $objArr = json_decode($json);</span><br><span class="line">        $hitokoto[<span class="string">'hitokoto'</span>] = $objArr-&gt;hitokoto;</span><br><span class="line">        $hitokoto[<span class="string">'from'</span>] = $objArr-&gt;from;</span><br><span class="line">        <span class="keyword">if</span> ($objArr-&gt;hitokoto)&#123;</span><br><span class="line">            <span class="keyword">return</span> $hitokoto;</span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="string">'一言数据获取失败'</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">bot</span><span class="params">($content)</span></span>&#123;<span class="comment">//对图灵机器人的调用</span></span><br><span class="line">        $url = <span class="string">'http://www.tuling123.com/openapi/api?key=d8f68602b1e32dc211a4d85a87e12c90&amp;info='</span>.$content;</span><br><span class="line">        $json = file_get_contents($url);</span><br><span class="line">        $objArr = json_decode($json);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">switch</span> ($objArr-&gt;code)&#123;<span class="comment">//机器人一些异常处理返回内容进行匹配</span></span><br><span class="line">            <span class="keyword">case</span> <span class="number">100000</span>:</span><br><span class="line">                $text = <span class="keyword">new</span> Text([<span class="string">'content'</span>=&gt;$objArr-&gt;text]);</span><br><span class="line">                <span class="keyword">return</span> $text;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">case</span> <span class="number">200000</span>:</span><br><span class="line">                $text = <span class="keyword">new</span> Text([<span class="string">'content'</span>=&gt;$objArr-&gt;text.<span class="string">"\n"</span>.$objArr-&gt;url]);</span><br><span class="line">                <span class="keyword">return</span> $text;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">case</span> <span class="number">40001</span>:</span><br><span class="line">                $text = <span class="keyword">new</span> Text([<span class="string">'content'</span>=&gt;<span class="string">'小冰KEY错误，请联系管理员'</span>]);</span><br><span class="line">                <span class="keyword">return</span> $text;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">case</span> <span class="number">40002</span>:</span><br><span class="line">                $text = <span class="keyword">new</span> Text([<span class="string">'content'</span>=&gt;<span class="string">'小冰没听清你说的是什么？请说明白一些~'</span>]);</span><br><span class="line">                <span class="keyword">return</span> $text;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">case</span> <span class="number">40004</span>:</span><br><span class="line">                $text = <span class="keyword">new</span> Text([<span class="string">'content'</span>=&gt;<span class="string">'小冰今天累了~明天再来和我玩吧'</span>]);</span><br><span class="line">                <span class="keyword">return</span> $text;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">case</span> <span class="number">40007</span>:</span><br><span class="line">                $text = <span class="keyword">new</span> Text([<span class="string">'content'</span>=&gt;<span class="string">'小冰出现了一些异常，请认真对待我！'</span>]);</span><br><span class="line">                <span class="keyword">return</span> $text;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">            <span class="keyword">default</span>:</span><br><span class="line">                $text = <span class="keyword">new</span> Text([<span class="string">'content'</span>=&gt;<span class="string">"小冰并不想和你说话，并向你扔了一只猫！"</span>]);</span><br><span class="line">                <span class="keyword">return</span> $text;</span><br><span class="line">                <span class="keyword">break</span>;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<h2 id="其他调用SDK方法"><a href="#其他调用SDK方法" class="headerlink" title="其他调用SDK方法"></a>其他调用SDK方法</h2><h3 id="可以通过容器自动注入"><a href="#可以通过容器自动注入" class="headerlink" title="可以通过容器自动注入"></a>可以通过容器自动注入</h3><figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?php</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">namespace</span> <span class="title">App</span>\<span class="title">Http</span>\<span class="title">Controllers</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">use</span> <span class="title">EasyWeChat</span>\<span class="title">Foundation</span>\<span class="title">Application</span>;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">WechatController</span> <span class="keyword">extends</span> <span class="title">Controller</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="function"><span class="keyword">function</span> <span class="title">demo</span><span class="params">(Application $wechat)</span></span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// $wechat 则为容器中 EasyWeChat\Foundation\Application 的实例</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="使用门面-facades"><a href="#使用门面-facades" class="headerlink" title="使用门面(facades)"></a>使用门面(facades)</h3><figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$wechatServer = EasyWeChat::server(); <span class="comment">// 服务端</span></span><br><span class="line">$wechatUser = EasyWeChat::user(); <span class="comment">// 用户服务</span></span><br></pre></td></tr></table></figure>
<h2 id="问题解决"><a href="#问题解决" class="headerlink" title="问题解决"></a>问题解决</h2><p>在实际上线的项目 ，有可能会遇到各种问题，所以要开启Log日志debug，我就遇见了SSL证书问题，这里请参考：easyWechat的官方<a href="https://easywechat.org/zh-cn/docs/troubleshooting.html#curl-60-SSL-certificate-problem-unable-to-get-local-issuer-certificate" target="_blank" rel="noopener">疑难解答</a>，来解决这个问题。</p>
<h2 id="相关API"><a href="#相关API" class="headerlink" title="相关API"></a>相关API</h2><p>Minecraft Mojang 官方API：<a href="https://sessionserver.mojang.com/session/minecraft/profile/" target="_blank" rel="noopener">https://sessionserver.mojang.com/session/minecraft/profile/</a></p>
<p>第三方Minecraft皮肤查询接口：<a href="https://crafatar.com/" target="_blank" rel="noopener">https://crafatar.com/</a></p>
<p>图灵机器人API： <a href="http://www.tuling123.com/" target="_blank" rel="noopener">http://www.tuling123.com/</a></p>
<p>一言API ： <a href="http://hitokoto.cn/api" target="_blank" rel="noopener">http://hitokoto.cn/api</a></p>
<h2 id="演示"><a href="#演示" class="headerlink" title="演示"></a>演示</h2><blockquote>
<p>公众号：Game5Hei</p>
</blockquote>
<p><img src="http://oqca0721d.bkt.clouddn.com/IMG_0112.PNG" alt="微信消息"></p>
<p><img src="http://oqca0721d.bkt.clouddn.com/wechat2.png" alt="微信小冰"></p>
<p><img src="http://oqca0721d.bkt.clouddn.com/kitokoto.png" alt="一言"></p>
<p><img src="http://oqca0721d.bkt.clouddn.com/424cye1496637209.png" alt="功能翻译"></p>
<p><img src="http://oqca0721d.bkt.clouddn.com/gnh6gu1496637653.png" alt="高铁路线"></p>
<p><img src="http://oqca0721d.bkt.clouddn.com/2u4fcy1496638069.png" alt="去哪儿"></p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Laravel/" rel="tag"># Laravel</a>
          
            <a href="/tags/easyWechat/" rel="tag"># easyWechat</a>
          
            <a href="/tags/Wechat/" rel="tag"># Wechat</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/12/28/Laravel-5-3-学习笔记/" rel="next" title="Laravel 5.3 学习笔记">
                <i class="fa fa-chevron-left"></i> Laravel 5.3 学习笔记
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/06/13/Laravel搭建迷你博客/" rel="prev" title="Laravel搭建迷你博客">
                Laravel搭建迷你博客 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="lv-container" data-id="city" data-uid="MTAyMC8yOTUyMy82MDkx"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image" src="/images/avatar.gif" alt="Colorful_Ghost">
          <p class="site-author-name" itemprop="name">Colorful_Ghost</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
           
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">16</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">分类</span>
              
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">17</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="http://steamcommunity.com/id/233000/" target="_blank" title="Steam">
                  
                    <i class="fa fa-fw fa-steam"></i>
                  
                  Steam
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://wpa.qq.com/msgrd?v=3&uin=815666528&site=qq&menu=yes" target="_blank" title="QQ">
                  
                    <i class="fa fa-fw fa-qq"></i>
                  
                  QQ
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://t.me/Colorful_Ghost" target="_blank" title="Telegram">
                  
                    <i class="fa fa-fw fa-telegram"></i>
                  
                  Telegram
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-block">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.chaosgoo.com" title="Chaosgoo" target="_blank">Chaosgoo</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#环境与部署"><span class="nav-number">1.</span> <span class="nav-text">环境与部署</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#环境需求"><span class="nav-number">1.1.</span> <span class="nav-text">环境需求</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#开始部署"><span class="nav-number">1.2.</span> <span class="nav-text">开始部署</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置"><span class="nav-number">2.</span> <span class="nav-text">配置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用"><span class="nav-number">3.</span> <span class="nav-text">使用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#其他调用SDK方法"><span class="nav-number">4.</span> <span class="nav-text">其他调用SDK方法</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#可以通过容器自动注入"><span class="nav-number">4.1.</span> <span class="nav-text">可以通过容器自动注入</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用门面-facades"><span class="nav-number">4.2.</span> <span class="nav-text">使用门面(facades)</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#问题解决"><span class="nav-number">5.</span> <span class="nav-text">问题解决</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#相关API"><span class="nav-number">6.</span> <span class="nav-text">相关API</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#演示"><span class="nav-number">7.</span> <span class="nav-text">演示</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Colorful_Ghost</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>

  <p>Hosted by <a href="https://pages.coding.me" style="font-weight: bold">Coding Pages</a></p>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  






  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  


  




	





  





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  






  





  

  

  

  

</body>
</html>
